#ifndef _XDB_LOG_H
#define _XDB_LOG_H
#include <map>
#include <string>
#include "xdb_config.h"

#include <log4cxx/logger.h>
#include <log4cxx/logstring.h>
#include <log4cxx/propertyconfigurator.h>

namespace xdragonball
{


class ILog
{
public:
	virtual int print(char *arg, ...) = 0;
};

class LogMgr
{
public:
	~LogMgr();

	static LogMgr & log();
	static ILog *log(std::string name);

private:
	LogMgr();

	typedef std::map<std::string, ILog *> Dict;
	Dict _map;

};

static log4cxx::LoggerPtr g_liblog = log4cxx::Logger::getLogger("xdb");

};


#define XDB_LOG_DEBUG(msg) LOG4CXX_DEBUG(xdragonball::g_liblog, "["<<__FILE__<<":"<<__LINE__<<"] "<<msg)
#define XDB_LOG_TRACE(msg) LOG4CXX_TRACE(xdragonball::g_liblog, "["<<__FILE__<<":"<<__LINE__<<"] "<<msg)
#define XDB_LOG_INFO(msg) LOG4CXX_INFO(xdragonball::g_liblog, "["<<__FILE__<<":"<<__LINE__<<"] "<<msg)
#define XDB_LOG_WARN(msg) LOG4CXX_WARN(xdragonball::g_liblog, "["<<__FILE__<<":"<<__LINE__<<"] "<<msg)
#define XDB_LOG_ERROR(msg) LOG4CXX_ERROR(xdragonball::g_liblog, "["<<__FILE__<<":"<<__LINE__<<"] "<<msg)
#define XDB_LOG_ASSERT(condition, msg) LOG4CXX_WARN(g_liblog, condition, "["<<__FILE__<<":"<<__LINE__<<"] "<<msg)
#define XDB_LOG_FATAL(msg) LOG4CXX_FATAL(xdragonball::g_liblog, "["<<__FILE__<<":"<<__LINE__<<"] "<<msg)

#endif
